home *** CD-ROM | disk | FTP | other *** search
- function TServerCollection.GetBalancedName: string;
- var
- OldestTimeStamp: TDateTime;
- OldestServer, GoodCount, i: Integer;
- GoodServers: array of TServerItem;
- begin
- GoodCount := 0;
- OldestTimeStamp := Now;
- OldestServer := 0;
- SetLength(GoodServers, Count);
- for i:=0 to Pred(Count) do
- begin
- if (not Items[i].HasFailed) and (Items[i].Enabled) then
- begin
- GoodServers[GoodCount] := Items[i];
- if GoodServers[GoodCount].LastConnectionTimeStamp < OldestTimeStamp then
- begin
- OldestServer := GoodCount;
- OldestTimeStamp := GoodServers[GoodCount].LastConnectionTimeStamp
- end;
- Inc(GoodCount)
- end
- end;
- if GoodCount = 0 then
- raise EBrokerException.CreateRes(@SNoServers);
- GoodServers[OldestServer].LastConnectionTimeStamp := Now;
- Result := GoodServers[OldestServer].ComputerName;
- end;
-